﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SLEnvironmentSystem
{
    public class EnvironmentSystem:Singleton<EnvironmentSystem>,IInitable
    {
        public void Init()
        {

        }

        //public EnvironmentArea GetArea(Vector3 size)
        //{
        //    return GetArea();
        //}

        public EnvironmentArea GetArea(Vector3 size,string tag="")
        {
            GameObject go = new GameObject(tag+"Area" );
            //MeshFilter filter = go.AddComponent<MeshFilter>();
            //Mesh mesh = new Mesh();

            //mesh.vertices = new Vector3[]
            //{
            //    new Vector3(0, 0, 0),
            //    new Vector3(1, 0, 0),
            //    new Vector3(1, 1, 0),
            //    new Vector3(0, 1, 0),
            //    new Vector3(0, 1, 1),
            //    new Vector3(1, 1, 1),
            //    new Vector3(1, 0, 1),
            //    new Vector3(0, 1, 0),
            //};
            //设置三角形顶点顺序，顺时针设置


            //filter.mesh = mesh;
            Rigidbody rigidbody = go.AddComponent<Rigidbody>();
            rigidbody.useGravity = false;
            rigidbody.isKinematic = true;
            EnvironmentArea area = go.AddComponent<EnvironmentArea>();
            area.Tag = tag;
            area.SetSize(size);

            return area;
        }

    }
}

